/*
 * Forca_HMF.h
 *
 *  Created on: 03/09/2013
 *      Author: steiner
 */

#ifndef FORCA_HMF_H_
#define FORCA_HMF_H_

void forca(long, double*, double*, double[], double[], double[]);

#endif /* FORCA_HMF_H_ */

#include <stdio.h>
#include <math.h>

void forca(long n, double *mx, double *my, double *pos, double *forca, double *mass)
{
	long i;
	double aux1,aux2,sth[n],cth[n];

	*mx=0.0;
	*my=0.0;
	for (i = 0 ; i < n ; i++){
		aux1 = sin(pos[i]);
		aux2 = cos(pos[i]);
		*mx += aux2;
		*my += aux1;
		sth[i] = aux1;
		cth[i] = aux2;
	}

	*mx = *mx/((double) n);
	*my = *my/((double) n);

	for ( i = 0 ; i < n ; i++){
		forca[i] = mass[i]*cth[i]*(*my) - mass[i]*sth[i]*(*mx);
	}

	return;
}
